module WhoCharted
  module ChartFeatures
    module Markers
      module ClassMethods
        def accepted_arguments
          super + [:markers]
        end

        def argument_dictionary
          super.merge(:markers => 
                      {:key => 'chm', :method => :gather_markers})
        end
      end

      def self.included base
        base.extend(ClassMethods)
      end

      MARKER_TYPE_DICTIONARY = {
        :arrow => 'a',
        :cross => 'c',
        :rectangle => 'C',
        :diamond => 'd',
        :error_bar => 'E',
        :horizontal_line => 'h',
        # :other_horizontal_line => 'H',
        :circle => 'o',
        :square => 's',
        :veritcal_line => 'v',
        # :other_vertical_line => 'V'
        :x => 'x'
      }

      # TODO: this needs to be redone for the following issues:
      # 1 need to validate required elements for marker specs
      # 2 need to be able to pass in and process an array of marker specs
      # 3 need to properly handle the (optional) :which_points spec
      # 4 need to implement (optional) :z_order handling
      # 5 need to implement (optional) :offset handling
      # 6 may want to automatically handle :series_index based on array index, similar to gather_axis_range above
      def gather_markers
        "#{MARKER_TYPE_DICTIONARY[markers[:type]]},#{markers[:color]},#{markers[:series_index]},#{markers[:which_points]},#{markers[:size]}"
      end

      attr_reader :markers

      private 
      
      attr_writer :markers
    end
  end
end
